home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
TMEditor.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-26
|
27KB
|
1,068 lines
/* ******************************************************************* */
/* ** ** */
/* ** ATKeyboard Version 4.0 ** */
/* ** Copright (C) 1992-1994 by Thomas Dreibholz ** */
/* ** All rights reserved ** */
/* ** ** */
/* ** Tastaturtabellen-Editor ** */
/* ** ** */
/* ******************************************************************* */
#include "ATKeyboard.h"
EXTERN LONG KickstartVersion;
EXTERN UBYTE TastenTabelle[256];
EXTERN UBYTE *HelpName;
extern struct TextAttr OpalFontDef;
extern struct IntuiText Trennlinie_Text;
extern struct IntuiText Wirklich_Text;
extern struct Einstellungen Einstellungen;
extern struct KeyCodes *KeyCodes;
extern struct FileRequester *FileRequester;
extern struct MenuItem TM_Item[];
struct KeyTab *BackupKeys;
struct IntuiText TEdHilfe_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Hilfe zum Editor",
};
struct IntuiText TU_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Rücknahme aller Aktionen",
};
struct IntuiText Kopieren_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Taste kopieren",
};
struct IntuiText Tauschen_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Tasten tauschen",
};
struct IntuiText CodeTable_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"CodeTable-Datei",
};
struct IntuiText Translator_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Translator-Datei",
};
struct IntuiText ML_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Tastaturtabelle laden von",
};
struct IntuiText MS_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Tastaturtabelle sichern als",
};
struct IntuiText TE_Text=
{
AUTOFRONTPEN,AUTOBACKPEN,AUTODRAWMODE,AUTOLEFTEDGE,1,&OpalFontDef,
"Übernehmen und Beenden",
};
struct MenuItem TE_Item=
{
NULL,
5,30,300,10,
HIGHIMAGE|ITEMENABLED|ITEMTEXT|COMMSEQ,
0L,
&TE_Text,
&Wirklich_Text,
'Q',NULL
};
struct MenuItem Trennlinie02_Item=
{
&TE_Item,
5,20,300,10,
HIGHNONE|ITEMTEXT,
0L,
&Trennlinie_Text,
NULL,
0,NULL
};
struct MenuItem CS_Item=
{
NULL,
180,14,250,10,
HIGHCOMP|ITEMENABLED|COMMSEQ|ITEMTEXT,
0L,
&CodeTable_Text,
NULL,
'R',NULL
};
struct MenuItem TS_Item=
{
&CS_Item,
180,4,250,10,
HIGHCOMP|ITEMENABLED|COMMSEQ|ITEMTEXT,
0L,
&Translator_Text,
NULL,
'S',NULL
};
struct MenuItem CL_Item=
{
NULL,
180,14,250,10,
HIGHCOMP|ITEMENABLED|COMMSEQ|ITEMTEXT,
0L,
&CodeTable_Text,
NULL,
'W',NULL
};
struct MenuItem TL_Item=
{
&CL_Item,
180,4,250,10,
HIGHCOMP|ITEMENABLED|COMMSEQ|ITEMTEXT,
0L,
&Translator_Text,
NULL,
'L',NULL
};
struct MenuItem MS_Item=
{
&Trennlinie02_Item,
5,10,300,10,
HIGHCOMP|ITEMENABLED|ITEMTEXT,
0L,
&MS_Text,
NULL,
0,&TS_Item
};
struct MenuItem ML_Item=
{
&MS_Item,
5,0,300,10,
HIGHCOMP|ITEMENABLED|ITEMTEXT,
0L,
&ML_Text,
NULL,
0,&TL_Item
};
struct MenuItem Swap_Item=
{
NULL,
5,20,300,10,
HIGHCOMP|ITEMENABLED|ITEMTEXT|COMMSEQ,
0L,
&Tauschen_Text,
NULL,
'T',NULL
};
struct MenuItem Copy_Item=
{
&Swap_Item,
5,10,300,10,
HIGHCOMP|ITEMENABLED|ITEMTEXT|COMMSEQ,
0L,
&Kopieren_Text,
NULL,
'C',NULL
};
struct MenuItem TU_Item=
{
&Copy_Item,
5,0,300,10,
HIGHCOMP|ITEMENABLED|ITEMTEXT|COMMSEQ,
0L,
&TU_Text,
NULL,
'X',NULL
};
struct MenuItem TEdHilfe_Item=
{
NULL,
-235,0,300,10,
HIGHCOMP|ITEMENABLED|ITEMTEXT|COMMSEQ,
0L,
&TEdHilfe_Text,
NULL,
'H',NULL
};
struct Menu THilfe_Menu=
{
NULL,
560,0,70,10,
MENUENABLED,
"Hilfe",
&TEdHilfe_Item
};
struct Menu TBearbeiten_Menu=
{
&THilfe_Menu,
140,0,130,10,
MENUENABLED,
"Bearbeiten",
&TU_Item
};
struct Menu TDatei_Menu=
{
&TBearbeiten_Menu,
5,0,130,10,
MENUENABLED,
"Datei",
&ML_Item
};
#define MENU_DATEI 0
#define ITEM_LADEN 0
#define ITEM_SICHERN 1
#define SUBITEM_TRANSLATOR 0
#define SUBITEM_CODETABLE 1
#define ITEM_ENDE 3
#define MENU_BEARBEITEN 1
#define ITEM_UNDO 0
#define ITEM_KOPIEREN 1
#define ITEM_TAUSCHEN 2
#define MENU_HILFE 2
#define ITEM_HILFE 0
#define xITEMENABLED (0xffff-ITEMENABLED)
UBYTE Name[20];
UBYTE pos;
struct InputEvent ie=
{
NULL,IECLASS_RAWKEY,0,0,0
};
struct RawName
{
WORD Select;
UBYTE *Name;
};
struct RawName RawName[]={
0x45,"Escape",
0x50,"F1",
0x51,"F2",
0x52,"F3",
0x53,"F4",
0x54,"F5",
0x55,"F6",
0x56,"F7",
0x57,"F8",
0x58,"F9",
0x59,"F10",
0x46,"Del",
0x5f,"Help",
0x41,"Backspace",
0x66,"Amiga links",
0x67,"Amiga rechts",
0x64,"Alt links",
0x65,"Alt rechts",
0x60,"Shift links",
0x61,"Shift rechts",
0x63,"Control",
0x62,"Caps Lock",
0x40,"Space",
0x42,"Tab",
0x44,"Return",
0x43,"Enter",
0x4c,"Cursor auf",
0x4f,"Cursor ab",
0x4e,"Cursor rechts",
0x4d,"Cursor links",
0x5a,"Num Lock",
0x5b,"Scroll Lock",
0x5d,"Print Screen",
0x3d,"7/Home",
0x3e,"8/Cursor auf",
0x3f,"9/Seite auf",
0x2d,"4/Cursor links",
0x2e,"5",
0x2f,"6/Cursor rechts",
0x1d,"1/End",
0x1e,"2/Cursor ab",
0x1f,"3/Seite ab",
0x0f,"0/Insert",
0x3c,"./Del",
0x4a,"Ziffernblock: +",
0x5e,"Ziffernblock: -",
0x5c,"Ziffernblock: /",
0x0e,NULL,
0x1c,NULL,
0x2c,NULL,
0x3b,NULL,
-1,NULL
};
/* Sondertastenname ermitteln */
BOOL GetRawName(select)
UBYTE select;
{
REGISTER WORD i;
for(i=0;RawName[i].Select!=-1;i++)
{
if(RawName[i].Select==select)
{
if(RawName[i].Name!=NULL) sprintf(&Name,"<%s>",RawName[i].Name);
return(TRUE);
}
}
return(FALSE);
}
/* Tastenname ermitteln */
UBYTE *GetName(select)
UBYTE select;
{
UBYTE byte;
UBYTE anz;
BOOL res;
strcpy(&Name,"");
res=GetRawName(select);
if((res==FALSE)&&(select>=0x00)&&(select<0x40))
{
ie.ie_Code=select;
anz=RawKeyConvert(&ie,&byte,1L,NULL);
if(anz==1) sprintf(&Name,"<%c>",byte);
}
return(&Name);
}
/* Neue Tastenbelegung zeigen */
VOID ShowKey(rp,st,val,sel)
struct RastPort *rp;
UBYTE st,val,sel;
{
UBYTE str[32];
REGISTER UWORD x,y;
x=st*12;
y=62+x;
SetAPen(rp,0);
RectFill(rp,20,54+x,345,66+x);
SelectStdFPen(rp);
sprintf(&str,"$%02lx",sel);
WriteText(rp,20,y,&str);
WriteText(rp,60,y,"->");
sprintf(&str,"$%02lx",val);
WriteText(rp,90,y,&str);
sprintf(&str,"($%02lx)",val+BIT7);
WriteText(rp,130,y,&str);
WriteText(rp,200,y,GetName(sel));
}
/* Hex-Zeichen in Zahl wandeln */
UBYTE GetHex(chr)
UBYTE chr;
{
if((chr>='0')&&(chr<='9')) return(chr-48);
return(chr-55);
}
/* Editorzeile anzeigen */
VOID PrintS(win,select,value,upValue,phase)
struct Window *win;
UBYTE select;
UBYTE value;
UBYTE upValue;
UBYTE phase;
{
UBYTE str[75];
switch(phase)
{
case 0:
sprintf(&str,"$%02lx -> $%02lx ($%02lx) %s",select,value,upValue,GetName(select));
break;
case 1:
sprintf(&str,"$%02lx -> $%lx- ($--) %s",select,value,GetName(select));
break;
case 2:
sprintf(&str,"Kopieren [$%02lx -> $%02lx ($%02lx) %s]",select,value,upValue,GetName(select));
break;
case 3:
sprintf(&str,"Tauschen [$%02lx -> $%02lx ($%02lx) %s]",select,value,upValue,GetName(select));
break;
}
DrawMNTextBorder(win,90,38,350,12,&str);
}
/* Editor-Reset */
VOID ResetEditor(rp)
struct RastPort *rp;
{
REGISTER WORD i;
for(i=0;i<8;i++)
ShowKey(rp,i,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[pos+i],pos+i);
}
/* ASCII-Zeile schreiben */
VOID AWrite(fh,tex)
struct FileHandle *fh;
UBYTE *tex;
{
Write(fh,tex,strlen(tex));
}
UBYTE *Logo[]=
{
"***********************************************\n",
"**** ****\n",
"**** ATKeyboard 4.0 Translator File ****\n"
};
/* Translator-Datei schreiben */
VOID WriteTranslator(fh)
struct FileHandle *fh;
{
REGISTER WORD i;
UBYTE buf[64];
AWrite(fh,Logo[0]);
AWrite(fh,Logo[1]);
AWrite(fh,Logo[2]);
AWrite(fh,Logo[1]);
AWrite(fh,Logo[0]);
AWrite(fh,"\n\nPC <- Amiga <- Taste\n-----------------------\n");
for(i=0;i<=0x7f;i++)
{
sprintf(&buf,"$%02lx <- $%02lx <- %s\n",
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[i],
i,GetName(i));
AWrite(fh,&buf);
}
}
/* Zeile lesen */
BOOL ReadLine(fh,tex)
struct FileHandle *fh;
UBYTE *tex;
{
REGISTER WORD i,j,anz;
UBYTE byte;
anz=0;
for(i=0;i<79;i++)
{
j=Read(fh,&byte,1L);
if(j==0)
{
tex[anz]=0x00;
return(FALSE);
}
switch(byte)
{
case 13:
case 10:
tex[anz]=0x00;
return(TRUE);
break;
default:
tex[anz]=byte;
anz++;
break;
}
}
tex[79]=0x00;
return(TRUE);
}
/* Translator-Datei lesen */
VOID ReadTranslator(win,fh,pos,select)
struct Window *win;
struct FileHandle *fh;
UBYTE pos;
UBYTE select;
{
REGISTER WORD a,b,zeile;
REGISTER UBYTE anz;
REGISTER BOOL okay,res;
UBYTE byte;
UBYTE buf[80];
UBYTE TBuffer[128];
UBYTE *Titel;
Titel=win->Title;
SetWindowTitles(win,"Lade Translator-Datei...",-1L);
okay=FALSE;
anz=0;
zeile=0;
while(okay==FALSE)
{
res=ReadLine(fh,&buf);
zeile++;
if(res==TRUE)
{
if(buf[0]=='$')
{
buf[1]=toupper(buf[1]);
buf[2]=toupper(buf[2]);
a=b=-1L;
if( ((buf[1]>='0')&&(buf[1]<='9')) || ((buf[1]>='A')&&(buf[1]<='F')) ) a=GetHex(buf[1]);
if( ((buf[2]>='0')&&(buf[2]<='9')) || ((buf[2]>='A')&&(buf[2]<='F')) ) b=GetHex(buf[2]);
if((a==-1L)||(b==-1L))
{
if(a==-1L) a=1; else a=2;
sprintf(&buf,"%ld, %ld. Zeichen.",zeile,a);
Requester("Formatfehler in Zeile",&buf,"Okay",NULL);
okay=TRUE;
}
TBuffer[anz]=(a*16)+b;
anz++;
if(anz==128) okay=TRUE;
}
}
else
{
okay=TRUE;
}
}
if(anz==128)
{
for(a=0;a<=127;a++)
{
if(TBuffer[a]>=BIT7) TBuffer[a]-=BIT7;
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[a]=TBuffer[a];
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[a+BIT7]=TBuffer[a]+BIT7;
}
ResetEditor(win->RPort);
PrintS(win,0,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[select+BIT7],0);
}
else
{
sprintf(&buf,"%ld statt 128 Zeichen.",anz);
Requester("Die Translator-Datei enthält nur",&buf,"Okay",NULL);
}
SetWindowTitles(win,Titel,-1L);
}
/* Tasten-Test */
VOID TastenTest()
{
register struct Window *win;
register struct IntuiMessage *msg;
REGISTER ULONG Class;
REGISTER UWORD Code,Qualifier,i;
REGISTER BOOL ende;
ende=FALSE;
win=CreateStdWindow("Testen-Test -> Bitte Eingaben machen <-",
75,5,460,BorderHeight(),
CLOSEWINDOW|RAWKEY|INACTIVEWINDOW,
WINDOWDEPTH|WINDOWDRAG|WINDOWCLOSE|ACTIVATE);
if(win!=NULL)
{
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GetMsg(win->UserPort);
Class=msg->Class;
Code=msg->Code;
Qualifier=msg->Qualifier;
ReplyMsg(msg);
switch(Class)
{
case RAWKEY:
for(i=0;i<256;i++) TastenTabelle[i]=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[i];
Taste(Code,Qualifier);
break;
case INACTIVEWINDOW:
case CLOSEWINDOW:
ende=TRUE;
break;
}
}
DeleteStdWindow(win);
}
}
/* Editor-Hauptprogramm */
VOID TMEditor()
{
register struct Gadget *Gadget;
register struct Window *win;
register struct IntuiMessage *msg;
register struct RastPort *rp;
register struct FileHandle *fh;
struct PropInfo *PInfo;
struct Gadget *PGadget;
REGISTER UBYTE *k;
REGISTER ULONG Class;
REGISTER UWORD Code,ItemNum,MenuNum,SubItemNum;
REGISTER WORD i,j,id;
UBYTE Phase,UndoChar,copy;
BOOL ende,refresh,changed;
UBYTE Select;
UBYTE Value;
UBYTE STNum;
BackupKeys=AllocMem(256,MEMF_CLEAR|MEMF_PUBLIC);
if(BackupKeys==NULL) return;
CopyMem(&KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys,BackupKeys,256);
Select=0;
Phase=0;
STNum=0;
Value=0;
copy=0;
changed=FALSE;
UndoChar=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[0];
pos=0;
win=CreateStdWindow("ATKeyboard - Tastaturtabellen-Editor",
75,25,460,156+BorderHeight(),
GADGETUP|CLOSEWINDOW|VANILLAKEY|MENUPICK,
WINDOWDEPTH|WINDOWDRAG|WINDOWCLOSE|ACTIVATE|GIMMEZEROZERO);
if(win!=NULL)
{
10,40,340,10,
rp=win->RPort;
SetFont(rp,GetOpalFont());
CreateBoolGadget(win,10,5,210,12,"Einstellungen okay",10000);
CreateBoolGadget(win,230,5,210,12,"Einstellungen verwerfen",20000);
CreateBoolGadget(win,10,22,80,12,"Test",1000);
CreateBoolGadget(win,145,22,95,12,"Kopieren",2000);
CreateBoolGadget(win,245,22,95,12,"Tauschen",3000);
CreateBoolGadget(win,345,22,95,12,"Hilfe",4000);
for(i=0;i<8;i++)
CreateMinGadget(win,11,53+(i*12),358,12,i);
ResetEditor(rp);
PGadget=CreatePropGadget(win,375,53,65,98,0,0,0,512,500);
PInfo=PGadget->SpecialInfo;
DrawNBorder(win,10,53,360,98);
SelectStdFPen(rp);
WriteText(rp,20,48,"Auswahl:");
SetMenuStrip(win,&TDatei_Menu);
PrintS(win,0,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[0],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[BIT7],
0);
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GetMsg(win->UserPort);
Class=msg->Class;
Code=msg->Code;
Gadget=msg->IAddress;
ReplyMsg(msg);
switch(Class)
{
case VANILLAKEY:
changed=TRUE;
Code=toupper(Code);
refresh=FALSE;
if(((Code>='0')&&(Code<='9')) || ((Code>='A')&&(Code<='F')))
{
switch(Phase)
{
case 0:
Value=GetHex(Code);
PrintS(win,Select,Value,0,1);
Phase=1;
break;
case 1:
Value=(Value*16)+GetHex(Code);
if(Value>=BIT7) Value-=BIT7;
PrintS(win,Select,Value,Value+BIT7,0);
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select]=Value;
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7]=Value+BIT7;
Phase=0;
refresh=TRUE;
break;
}
}
else if((Code==13)&&(Phase==1))
{
PrintS(win,Select,Value,Value+BIT7,0);
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select]=Value;
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7]=Value+BIT7;
Phase=0;
refresh=TRUE;
}
else if(Code==27)
{
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select]=UndoChar;
Phase=0;
PrintS(win,Select,UndoChar,UndoChar+BIT7,0);
Value=UndoChar;
refresh=TRUE;
}
if(refresh==TRUE)
ShowKey(rp,STNum,Value,Select);
break;
case MENUPICK:
MenuNum=MENUNUM(Code);
ItemNum=ITEMNUM(Code);
SubItemNum=SUBNUM(Code);
switch(MenuNum)
{
case MENU_DATEI:
switch(ItemNum)
{
case ITEM_SICHERN:
switch(SubItemNum)
{
case SUBITEM_CODETABLE:
if(FileRequester!=NULL)
{
k=FileReq("CodeTable-Datei sichern:","#?.codetable");
}
else
{
k=StringAbfrage(FALSE,"Name der CodeTable-Datei:","");
}
if((strcmp(k,"")))
{
fh=Open(k,MODE_NEWFILE);
if(fh!=NULL)
{
Write(fh,&KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys,256);
Close(fh);
}
else
{
Requester("Konnte die CodeTable-Datei","nicht erstellen.","Okay",NULL);
}
}
break;
case SUBITEM_TRANSLATOR:
if(FileRequester!=NULL)
{
k=FileReq("Translator-Datei sichern:","#?.translator");
}
else
{
k=StringAbfrage(FALSE,"Name der Translator-Datei:","");
}
if((strcmp(k,"")))
{
fh=Open(k,MODE_NEWFILE);
if(fh!=NULL)
{
WriteTranslator(fh);
Close(fh);
}
else
{
Requester("Konnte die Translator-Datei","nicht erstellen.","Okay",NULL);
}
}
break;
}
break;
case ITEM_LADEN:
switch(SubItemNum)
{
case SUBITEM_CODETABLE:
if(FileRequester!=NULL)
{
k=FileReq("CodeTable-Datei laden:","#?.codetable");
}
else
{
k=StringAbfrage(FALSE,"Name der CodeTable-Datei:","");
}
if((strcmp(k,"")))
{
fh=Open(k,MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,&KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys,256);
changed=TRUE;
Close(fh);
}
else
{
Requester("Konnte die CodeTable-Datei","nicht laden.","Okay",NULL);
}
}
break;
case SUBITEM_TRANSLATOR:
if(FileRequester!=NULL)
{
k=FileReq("Translator-Datei laden:","#?.translator");
}
else
{
k=StringAbfrage(FALSE,"Name der Translator-Datei:","");
}
if((strcmp(k,"")))
{
fh=Open(k,MODE_OLDFILE);
if(fh!=NULL)
{
ReadTranslator(win,fh,pos,Select);
changed=TRUE;
Close(fh);
}
else
{
Requester("Konnte die Translator-Datei","nicht laden.","Okay",NULL);
}
}
break;
}
break;
case ITEM_ENDE:
ende=TRUE;
break;
}
break;
case MENU_BEARBEITEN:
switch(ItemNum)
{
case ITEM_UNDO:
CopyMem(BackupKeys,&KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys,256);
ResetEditor(rp);
PrintS(win,0,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7],0);
break;
case ITEM_KOPIEREN:
copy=1; changed=TRUE;
PrintS(win,Select,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7],2);
break;
case ITEM_TAUSCHEN:
copy=2; changed=TRUE;
PrintS(win,Select,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7],3);
break;
}
break;
case MENU_HILFE:
if(ItemNum==ITEM_HILFE) Help(HelpName,144);
break;
}
break;
case GADGETUP:
id=Gadget->GadgetID;
switch(id)
{
case 10000:
ende=TRUE;
break;
case 20000:
CopyMem(BackupKeys,&KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys,256);
ende=TRUE;
break;
case 500:
pos=PInfo->VertPot/512;
if(pos>=120) pos=120;
ResetEditor(rp);
break;
case 1000:
ClearMenuStrip(win);
TastenTest();
SetMenuStrip(win,&TDatei_Menu);
break;
case 2000:
if(copy==1) { j=0; copy=0; } else { j=2; copy=1; }
PrintS(win,Select,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7],j);
break;
case 3000:
if(copy==2) { j=0; copy=0; } else { j=3; copy=2; }
PrintS(win,Select,KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7],j);
break;
case 4000:
Help(HelpName,144);
break;
default:
if((id>=0)&&(id<=7))
{
switch(copy)
{
case 1:
copy=0;
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[pos+id] =KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select];
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[pos+id+BIT7]=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7];
ResetEditor(rp);
break;
case 2:
j=pos+id+BIT7;
i=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select];
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select]=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[pos+id];
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select+BIT7]=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[j];
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[pos+id]=i;
KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[j]=i+BIT7;
copy=0;
ResetEditor(rp);
break;
default:
Select=pos+id;
Phase=0;
STNum=id;
break;
}
UndoChar=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[Select],
PrintS(win,Select,UndoChar,UndoChar+BIT7,0);
}
}
break;
case CLOSEWINDOW:
if(changed==TRUE)
{
ende=UsePrefs();
if(ende==FALSE)
{
CopyMem(BackupKeys,&KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys,256);
}
}
ende=TRUE;
break;
}
}
ClearMenuStrip(win);
DeleteStdWindow(win);
for(i=0;i<256;i++) TastenTabelle[i]=KeyCodes->KeyTab[Einstellungen.Tastaturmodus].Keys[i];
}
FreeMem(BackupKeys,256);
}
/* Modusname ändern/Modus (de)aktivieren */
VOID TMOnOff()
{
REGISTER ULONG Class;
REGISTER BOOL bool,neu,changed;
REGISTER WORD i,j;
UBYTE *Name[8];
struct Gadget *OnOff_Gadget[7];
register struct Gadget *g;
register struct Window *win;
register struct IntuiMessage *msg;
win=CreateStdWindow("ATKeyboard - Tastaturmodus (de)aktivieren",
75,20,465,153+BorderHeight(),CLOSEWINDOW|GADGETUP|VANILLAKEY,
WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|ACTIVATE|GIMMEZEROZERO);
if(win!=NULL)
{
SetFont(win->RPort,GetOpalFont());
CreateBoolGadget(win,10,5,210,12,"Einstellungen okay",1000);
CreateBoolGadget(win,230,5,210,12,"Einstellungen verwerfen",2000);
CreateBoolGadget(win,10,24,100,12,"Hilfe",4000);
for(i=43,j=0;j<7;i+=15,j++)
{
if(KeyCodes->KeyTab[j+1].Valid)
{
OnOff_Gadget[j]=CreateSToggleGadget(win,10,i,100,12,"Aktiv",j);
}
else
{
OnOff_Gadget[j]=CreateNToggleGadget(win,10,i,100,12,"Aktiv",j);
}
}
for(i=24,j=0;j<8;i+=15,j++)
{
Name[j]=CreateStringGadget(win,130,i,310,12,&KeyCodes->KeyTab[j].Name[2],28,100);
if(j==0) i+=4;
}
bool=neu=changed=FALSE;
while(bool==FALSE)
{
WaitPort(win->UserPort);
msg=GetMsg(win->UserPort);
Class=msg->Class;
j=msg->Code;
g=msg->IAddress;
switch(Class)
{
case CLOSEWINDOW:
bool=TRUE;
if(changed==TRUE) neu=UsePrefs();
break;
case GADGETUP:
switch(g->GadgetID)
{
case 4000:
Help(HelpName,145);
break;
case 1000:
neu=TRUE; bool=TRUE;
break;
case 2000:
bool=TRUE;
break;
default:
changed=TRUE;
break;
}
break;
case VANILLAKEY:
if(j==13) bool=TRUE;
break;
}
ReplyMsg(msg);
}
DeleteStdWindow(win);
if(neu==TRUE)
{
for(i=0;i<=6;i++)
{
if(OnOff_Gadget[i]->Flags & SELECTED)
{
TM_Item[i+1].Flags |= ITEMENABLED;
KeyCodes->KeyTab[i+1].Valid=1;
}
else
{
TM_Item[i+1].Flags &= xITEMENABLED;
KeyCodes->KeyTab[i+1].Valid=0;
}
}
for(i=0;i<=7;i++)
{
strcpy(&KeyCodes->KeyTab[i].Name," ");
strcpy(&KeyCodes->KeyTab[i].Name[2],Name[i]);
}
NeuerModus(Einstellungen.Tastaturmodus,FALSE);
}
}
}